from copy import copy
class MAsort:
    def __init__(self,mode=None):
        self.mode=mode
        if mode in ["long","buy"]:
            self.oncalc = self.oncalc_long
        elif mode in ["short","sell"]:
            self.oncalc = self.oncalc_short
        else:
            self.oncalc=self.oncalc0
    def oncalc0(self,*b,timekey=None):
        if None not in b:
            b=list(b)
            a=copy(b)
            b.sort()
            if a==b:
                return "sell"
            b.sort(reverse=True)
            if a==b:
                return "buy"
            else:
                return None
        else:
            return None
    def oncalc_short(self,*b,timekey=None):
        if None not in b:
            b=list(b)
            a=copy(b)
            b.sort()
            if a==b:
                return "sell"
            else:
                return None
        else:
            return None
    def oncalc_long(self,*b,timekey=None):
        if None not in b:
            b=list(b)
            a=copy(b)
            b.sort(reverse=True)
            if a==b:
                return "buy"
            else:
                return None
        else:
            return None
